/*
 * Copyright (c) 2020 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

#ifndef OHOS_MAIN_ABILITY_SLICE_H
#define OHOS_MAIN_ABILITY_SLICE_H

#include <ability_loader.h>
#include <functional>
#include <utility>
#include <securec.h>
#include <stdio.h>
#include <components/ui_image_view.h>
#include <components/ui_surface_view.h>

#include "event_listener.h"
#include "camera_manager.h"

namespace OHOS {
class CameraAbilitySlice : public AbilitySlice {
public:
    CameraAbilitySlice() = default;
    ~CameraAbilitySlice() override;

protected:
    void OnStart(const Want &want) override;
    void OnInactive() override;
    void OnActive(const Want &want) override;
    void OnBackground() override;
    void OnStop() override;

private:
    EventListener *buttonListener_ { nullptr };
    SampleCameraManager *cam_manager {nullptr};

    UISurfaceView *surfaceView {nullptr};
    UIImageView *backBttn {nullptr};
    UIImageView *backIcon {nullptr};


    void SetHead();

    static constexpr int BACK_LABEL_X = 24;
    static constexpr int BACK_LABEL_Y = 24;
    static constexpr int BACK_LABEL_W = 48;
    static constexpr int BACK_LABEL_H = 48;

    static constexpr int BACK_AREA_X = 0;
    static constexpr int BACK_AREA_Y = 0;
    static constexpr int BACK_AREA_W = 96;
    static constexpr int BACK_AREA_H = 96;

    static constexpr int CAMERA_START_X = 0;
    static constexpr int CAMERA_START_Y = 0;
    static constexpr int CAMERA_WIDTH = 960;
    static constexpr int CAMERA_HEIGHT = 480;

    static constexpr int IMAGE_WIDTH = 1920;
    static constexpr int IMAGE_HEIGHT = 1080;

    static constexpr int MAX_PATH_LENGTH = 512;

    static constexpr int CAMERA_READY_TIMEOUT = 5;

    static constexpr char *BACK_ICON_PATH = "Hoods/res/image/ic_back1.png";

};
}

#endif // OHOS_MAIN_ABILITY_SLICE_H
